<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>供需对接服务系统--项目列表</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        width: 100%;
        overflow-y: scroll;
    }

    .widthle {
        width: 44%;
    }

    .widinput {
        width: 45% !important;
    }

</style>

<body>
<!--头部-->

<!--容器-->
<div class="container clearfix">
    <!--右侧内容-->
    <div class="Right fr mt10">
        <div class="screening screeningOne whitebg clearfix">
            <form id="form-qurey">
                <ul class="clearfix fl" style="width: 100%;">
                    <li style="width: 20%;">
                        <label class="fl widthle">项目类型:</label>
                        <select name="projectType" id="projectType" class="widinput">
                            <option value="">全部</option>
                            <#list projectTypeList as vo>
                                <option value="${vo.badtCode}">${vo.badtName}</option>
                            </#list>
                        </select>
                    </li>
                    <li style="width: 50%;">
                        <label class="fl" style="width: 25%;">总工期截止时间:</label>
                        <input type="text" style="border: 1px solid #DDDDDD;width: 25%;" name="startDate" id="startDate"
                               autocomplete="off" placeholder="开始时间">
                        至
                        <input type="text" style="border: 1px solid #DDDDDD;width: 25%;" name="endDate" id="endDate"
                               autocomplete="off" placeholder="结束时间">
                    </li>
                    <li style="width: 25%;text-align: end;">
                        <button type="button" class="layui-btn layui-btn-normal" style="width:65px; height:40px"
                                onclick="query()">筛选
                        </button>
                        <button type="button" class="layui-btn layui-btn-normal"
                                style="width:65px; height:40px;background-color: #FF5722;" onclick="resetQuery()">重置
                        </button>
                    </li>
                </ul>
            </form>
        </div>
        <div class="project whitebg">
            <div class="layui-row">
                <div class="layui-col-md3 layui-col-md-offset9">
                    <@shiro.hasPermission name="search:export">
                    <input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel"
                           onclick="exportExcelPro()">
                    </@shiro.hasPermission>
                    <@shiro.hasPermission name="search:view">
                    <input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel"
                           onclick="viewExcelPro()">
                    </@shiro.hasPermission>
                </div>
            </div>
            <table id="tableList" class="layui-hide" lay-filter="tableList"></table>
        </div>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript">
    var layer;
    var form = layui.form;
    var table = null;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;


    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });
    });

    function query() {
        //项目类型
        var projectType = $('#projectType').val();
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();
        var jsondata = {
            projectType: projectType,
            startDate: startDate,
            endDate: endDate
        };
        table.reload('tableList', {where: jsondata});
    }

    function resetQuery() {
        document.getElementById('form-qurey').reset();
        var jsondata = {
            projectType: '',
            startDate: '',
            endDate: ''
        };
        table.reload('tableList', {where: jsondata});
    }

    function exportExcelPro() {
        var projectType = $('#projectType').val();
        var date = new Date();
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();
        //获取全部数据:
        var url = '/search/buProjectInfo/exportExcelPro?a_=' + Math.random() + "&exCode=001&projectType=" + projectType + "&endDate=" + endDate + "&startDate=" + startDate;
        location.href = url;
    }

    function viewExcelPro() {
        var projectType = $('#projectType').val();
        var date = new Date();
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();
        var json = {
            exCode: "001",
            startDate: startDate,
            endDate: endDate,
            projectType: projectType
        }
        layerAjaxGet('/search/buProjectInfo/viewExcelPro', json, '', function (res) {
            if (res.flag) {
                if (res.data) {
                    var w = ($(window).width() * 0.8);
                    var h = ($(window).height() * 0.8);
                    POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
                }
            }
        })


    }


    layui.use('table', function () {
        table = layui.table;
        element = element;
        //方法级渲染
        tableIns = table.render({
            id: 'tableList',
            elem: '#tableList',
            url: '/search/buProjectInfo/proFinishlvList',
            height: "auto",
            page: true,
            cols: [[
                {
                    title: '序号', width: '10%', align: "center", templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {field: 'projectType', title: '项目类型', width: '20%', align: "center", sort: true},
                {field: 'totalNum', title: '项目总数', width: '20%', align: "center", sort: true},
                {field: 'finishNum', title: '实际完成项目数', width: '20%', align: "center", sort: true},
                {field: 'finishLv', title: '完成率', width: '35%', align: "center", sort: true}
            ]],
            done: function (res, currentCount) {
                //***重点***：table渲染完成后渲染element进度条
                element.render();
                $(".layui-table-page select").css("width", "80px");

            }
        });
        //监听工具条
        table.on('tool(tableList)', function (obj) {
            var data = obj.data;
            var that = $(this);
            if (obj.event === 'resetPassword') {
                parent.layer.confirm('确定重置密码？', function (index) {
                    var userId = data.userId;
                    layerAjax("resetPassword", {id: userId}, "", function (d) {
                        if (d.flag) {
                            parent.layer.close(index);
                            layer.msg("操作成功", {icon: 1});
                            tableIns.reload();
                        } else {
                            layer.msg("操作失败", {icon: 2});
                        }
                    })
                });
            }
        });
    });


    function showDetail(id, projectName) {
        window.parent._showtab('xm_v' + id, '查看-' + projectName, '/supplier/projectManager/projectDetail?type=v&supProjectId=' + id);
    }

    // 已开发票金额
    function ylfpje(id) {
        var projectId = id;
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var url = "/search/buProjectInfo/viewYKfP?projectId=" + projectId;
        parent.layer.open({
            id: 'form-list',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            success: function (layero) {
                layero.find('.layui-layer-min').remove();
            }
        });


    }


    function provinceChange(object) {
        var code = $(object).find('option:selected').val();
        if (code == "") {
            return;
        }
        layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
            if (d.flag == true) {
                $(object).next().empty().append("<option value=''>选择市</option>");
                for (var i = 0; i < d.data.length; i++) {
                    $("#city").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                }
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });


    };

    function cityChange(object) {
        var code = $(object).find('option:selected').val();
        if (code == "") {
            return;
        }
        layerAjaxGet('/sys/register/getOrganize', {"code": code}, '', function (d) {
            if (d.flag == true) {
                $(object).next().empty().append("<option value=''>选择区县</option>");
                for (var i = 0; i < d.data.length; i++) {
                    $("#county").append("<option value='" + d.data[i].code + "'>" + d.data[i].name + "</option>");
                }
            } else {
                layer.msg(d.msg, {icon: 2});
            }
        });


    }

    $(function () {
        //回车事件
        $(document).keydown(function (e) {
            // 兼容FF和IE和Opera
            var theEvent = e || window.event;
            var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
            if (code == 13) {
                query();
            }
            return true;
        });
    })

    //重置
    function resetQuery(){
        $("#projectType").val('');
        $("#startDate").val('');
        $("#endDate").val('');
        var jsondata = {
            projectType: "",
            startDate: "",
            endDate: ""
        }
        table.reload('tableList', {where: jsondata});
    }

</script>
</body>

</html>
